function dGemricdcm2Dtonii3D(basedir,serie)

% Load all images in directory and saves as one 3D nifti image
% In the basedir should be all the volunteerdirs, 'locations.mat' and
% 'Estimated_parameters.mat'
% Henk Smit
    
    cd(basedir)
    load('locations.mat')
    
    IRdir = locations(serie).loc(1,1).dir;
    
    cd(IRdir);
    cd ..
    d=dir;

    for i=3:size(d,1)
        if size(char(regexp(d(i).name,'SPGR', 'match')),2)>=1
            directory = d(i).name;
            [tstimg, info_structure] = loaddata([directory filesep], 1 , 1.5);
            tstimg = squeeze(tstimg);
            T = affineTransformFromDicominfo( info_structure );
            [nii] = make_niiT(uint16(tstimg), T);
            save_nii( nii, [directory, filesep,'3D.nii'])
        end
end